package com.ruoyi.paper.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.paper.domain.QtPaperTkNums;
import com.ruoyi.paper.service.IQtPaperTkNumsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 试卷题数Controller
 * 
 * @author zqq
 * @date 2021-11-23
 */
@RestController
@RequestMapping("/paper/TypeNums")
public class QtPaperTkNumsController extends BaseController
{
    @Autowired
    private IQtPaperTkNumsService qtPaperTkNumsService;

    /**
     * 查询试卷题数列表
     */
    @PreAuthorize("@ss.hasPermi('paper:TypeNums:list')")
    @GetMapping("/list")
    public TableDataInfo list(QtPaperTkNums qtPaperTkNums)
    {
        startPage();
        List<QtPaperTkNums> list = qtPaperTkNumsService.selectQtPaperTkNumsList(qtPaperTkNums);
        return getDataTable(list);
    }

    /**
     * 导出试卷题数列表
     */
    @PreAuthorize("@ss.hasPermi('paper:TypeNums:export')")
    @Log(title = "试卷题数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QtPaperTkNums qtPaperTkNums)
    {
        List<QtPaperTkNums> list = qtPaperTkNumsService.selectQtPaperTkNumsList(qtPaperTkNums);
        ExcelUtil<QtPaperTkNums> util = new ExcelUtil<QtPaperTkNums>(QtPaperTkNums.class);
        return util.exportExcel(list, "试卷题数数据");
    }

    /**
     * 获取试卷题数详细信息
     */
    @PreAuthorize("@ss.hasPermi('paper:TypeNums:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(qtPaperTkNumsService.selectQtPaperTkNumsById(id));
    }

    /**
     * 新增试卷题数
     */
    @PreAuthorize("@ss.hasPermi('paper:TypeNums:add')")
    @Log(title = "试卷题数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QtPaperTkNums qtPaperTkNums)
    {
        return toAjax(qtPaperTkNumsService.insertQtPaperTkNums(qtPaperTkNums));
    }

    /**
     * 修改试卷题数
     */
    @PreAuthorize("@ss.hasPermi('paper:TypeNums:edit')")
    @Log(title = "试卷题数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QtPaperTkNums qtPaperTkNums)
    {
        return toAjax(qtPaperTkNumsService.updateQtPaperTkNums(qtPaperTkNums));
    }

    /**
     * 删除试卷题数
     */
    @PreAuthorize("@ss.hasPermi('paper:TypeNums:remove')")
    @Log(title = "试卷题数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(qtPaperTkNumsService.deleteQtPaperTkNumsByIds(ids));
    }
}
